﻿@model DissProject.Site.Models.RegisterModel
@{
    ViewBag.Title = "Регистрация";
    ViewBag.Message = "Създаване на акаунт.";
}



@{
    var roles = new List<SelectListItem>();
    roles.Add(new SelectListItem() { Text = "Студент", Value = "Student" });
    roles.Add(new SelectListItem() { Text = "Преподавател", Value = "Teacher" });
    roles.Add(new SelectListItem() { Text = "Докторант", Value = "PhdStudent" });
}

<section id="registerForm">
<hgroup class="title">
  @*  <h1>@ViewBag.Title.</h1>*@
</hgroup>

    <h2>Въведете своите данни.</h2>
    <br/>
@using (Html.BeginForm("Register", "Account", FormMethod.Post, new {@id="post-form"}))
{
    @Html.AntiForgeryToken()
    @Html.ValidationSummary()

    <fieldset>
        <legend>Регистрационна форма</legend>
            
               <div class="editor-label">
                    @Html.LabelFor(m => m.UserName)
                </div>
                <div class="editor-field">
                    @Html.TextBoxFor(m => m.UserName)
                    @Html.ValidationMessageFor(m => m.UserName)
                </div>
            
                <div class="editor-label">
                    @Html.LabelFor(m => m.Password)
                 </div>
                <div class="editor-field">
                    @Html.PasswordFor(m => m.Password)
                    @Html.ValidationMessageFor(m => m.Password)
                </div>
             
                <div class="editor-label">
                    @Html.LabelFor(m => m.ConfirmPassword)
                </div>
                <div class="editor-field">
                    @Html.PasswordFor(m => m.ConfirmPassword)
                    @Html.ValidationMessageFor(m => m.ConfirmPassword)
                </div>
                
                <div class="editor-label">
                    @Html.LabelFor(m => m.FirstName)
                </div>
                <div class="editor-field">
                    @Html.EditorFor(m => m.FirstName)                    
                    @Html.ValidationMessageFor(m => m.FirstName)
                </div>

                <div class="editor-label">
                    @Html.LabelFor(m => m.LastName)
                </div>
                <div class="editor-field">
                    @Html.EditorFor(m => m.LastName)
                    @Html.ValidationMessageFor(m => m.LastName)
                </div>

                <div class="editor-label">
                    @Html.LabelFor(m => m.SecondName)
                </div>
                <div class="editor-field">
                    @Html.EditorFor(m => m.SecondName)
                    @Html.ValidationMessageFor(m => m.SecondName)
                </div>
                
                <div class="editor-label">
                    @Html.LabelFor(m => m.Address)
                </div>
                <div class="editor-field">
                    @Html.EditorFor(m => m.Address)
                    @Html.ValidationMessageFor(m => m.Address)
                </div>
                
                <div class="editor-label">
                    @Html.LabelFor(m => m.PhoneNumber)
                </div>
                <div class="editor-field">
                    @Html.EditorFor(m => m.PhoneNumber)
                    @Html.ValidationMessageFor(m => m.PhoneNumber)
                </div>
                
                <div class="editor-label">
                    @Html.LabelFor(m => m.Role)
                </div>
                <div class="editor-field">

                    @Html.DropDownListFor(m => m.Role, roles, "---избери---", new { @class = "SelectedItemDropDown" })
                    @Html.ValidationMessageFor(m => m.Role)
                </div>

        <div id="ajax-call">

        </div>
        <input type="submit" value="Регистрация" />
    </fieldset>
}
<//section>

@section Scripts {
   
    <script src="http://modernizr.com/igsb-highlights/modernizr-latest.js"></script>
    @Scripts.Render("~/bundles/jqueryval")
    @Scripts.Render("~/bundles/jqueryui")
    @Styles.Render("~/Content/themes/base/css")
   

        <script type="text/javascript">
            $(document).ready(function () {
                $("#Role option:first").attr("selected", true);
                $(".SelectedItemDropDown").change(function () {

                    var val = $(this).val();
                    //if (val == "Teacher") {
                    //    $("#DateOfApproval").datepicker();
                    //}
                    $("#ajax-call").empty();
                    $("#post-form").attr("action", "Register" + val);
                    $.post("PersonalInfo", { id: val },
                        function (data) {
                            $("#ajax-call").html(data);
                            $('form').removeData('validator');
                            $('form').removeData('unobtrusiveValidation');
                            $.validator.unobtrusive.parse('form');
                        });

                })

            });
        </script>
}